package com.wench.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

//  实现Runnable接口
class MyThread1 implements Runnable {

    @Override
    public void run() {

    }
}

//  实现Callable接口
class MyThread2 implements Callable {

    @Override
    public Integer call() throws Exception {
        return 1024;
    }
}

public class Demo1 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        FutureTask<Integer> futureTask = new FutureTask<>(() -> {
            System.out.println(Thread.currentThread().getName() + " come in callable");
            return 1024;
        });

        new Thread(futureTask, "wench").start();

        System.out.println(futureTask.get());

    }
}
